import time
import pandas as pd
from tqdm import tqdm
from view.search import search_bvid
from view.go_video import get_video_data

keyword = "杰哥"
    columns = ['title', 'up', 'mid', 'bvid', 'play', 'banger', 'like', 'many', 'fans', 'create_time', 'img_path']
if __name__ == '__main__':
    start = time.time()
    id, url, img_path = search_bvid(keyword)

    df = pd.DataFrame(index=[i for i in range(len(id))], columns=columns)
    for i in tqdm(range(len(id))):
        title, up, mid, bvid, play, banger, like, many, fans, create_time = get_video_data(id[i])
        df.loc[i, columns] = title, up, mid, bvid, play, banger, like, many, fans, create_time, img_path[i]

    df.to_excel('./data/data.xlsx', index=False, encoding='utf-8', sheet_name='1')
    print("用时：", time.time() - start)
